﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using QuanLyDuocPham.Controllers.QuanLyHeThong.DanhMuc;

namespace QuanLyDuocPham.View.QuanLyHeThong.DanhMuc
{
    /// <summary>
    /// Interaction logic for CALAMVIEC_Add_View.xaml
    /// </summary>
    public partial class CALAMVIEC_Add_View : Window
    {
        public CALAMVIEC_Add_View()
        {
            InitializeComponent();
        }
        string ma_ca;
        public string _ma_ca
        {
            set
            {
                ma_ca = value;
            }
        }
        CALAMVIEC_Control cactrl = new CALAMVIEC_Control();
        public delegate void added();
        public added done;
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            cactrl.addData(ma_ca, txtDien_Giai, cmbGioBD, cmbPhutBD, cmbGioKT, cmbPhutKT);
            txtDien_Giai.Clear();
            ma_ca=cactrl.loadID_moi();
            cmbGioBD.SelectedItem = null;
            cmbGioKT.SelectedItem = null;
            cmbPhutBD.SelectedItem = null;
            cmbPhutKT.SelectedItem = null;

            if (done != null)
            {
                done();
            }
        }

        private void btnBack_Click(object sender, RoutedEventArgs e)
        {
            this.Close();

        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ma_ca = cactrl.loadID_moi();

            LoadComboboxTG(cmbGioBD, cmbGioKT, cmbPhutBD, cmbPhutKT);
            
        }
        private void LoadComboboxTG(ComboBox cmbGio_TGBD, ComboBox cmbGio_TGKT, ComboBox cmbPhut_TGBD, ComboBox cmbPhut_TGKT)
        {
            for (int i = 0; i < 24; i++)
            {
                if (i < 10)
                {
                    cmbGio_TGKT.Items.Add("0" + i.ToString());
                    cmbGio_TGBD.Items.Add("0" + i.ToString());
                }
                else
                {
                    cmbGio_TGBD.Items.Add(i.ToString());
                    cmbGio_TGKT.Items.Add(i.ToString());
                }
            }
            for (int i = 0; i < 59; i++)
            {
                if (i < 10)
                {
                    cmbPhut_TGBD.Items.Add("0" + i.ToString());
                    cmbPhut_TGKT.Items.Add("0" + i.ToString());
                }
                else
                {
                    cmbPhut_TGBD.Items.Add(i.ToString());
                    cmbPhut_TGKT.Items.Add(i.ToString());
                }
            }
        }
    }
}
